<?
    abstract class Principio_Mapper extends PrincipioLab_Mapper
    {
        public static function getPrefix() { return "Principio"; }


        public static function reportException(Exception &$ex)
        {
            return Principio_Common::error("EXCEPTION: File: [".$ex->getFile().":".$ex->getLine()."] Reason: [".$ex->getMessage()."] Trace: [".$ex->getTraceAsString()."]");
        }


        public static function searchInDB($db_table_obj, $search_fields, $search_string)
        {
            $select = $db_table_obj->select();
            $i = 0;
            foreach ($search_fields as $key => $value)
            {
                if ($i == 0)
                    $select->where("$key LIKE?", "%$search_string%");
                else
                    $select->orWhere("$key LIKE?", "%$search_string%");
                $i++;
            }
            $result = $db_table_obj->fetchAll($select)->toArray();

            return $result;
        }
    };
?>